<template>
  <div class="header">
    <div class="header-title">小白作业管理系统</div>
    <div class="header-type">
      <span @click="setModelType">{{ modelType }}</span>
      <span>English</span>
      <span @click="exit">退出</span>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {ref, defineProps} from "vue"
import {useRouter} from "vue-router"
const modelType = ref("")
const router = useRouter()
const props = defineProps({
  setModelType: {
    type: Function
  }
})
const exit = () => {
  window.localStorage.removeItem("token")
  router.push({
    name: "login"
  })
}
modelType.value = window.localStorage.getItem("modelType")
  ? window.localStorage.getItem("modelType")!
  : "teacher"
const setModelType = () => {
  props.setModelType!()
  modelType.value = window.localStorage.getItem("modelType")!
}
</script>

<style lang="scss" scoped>
.header {
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(153, 204, 255, 0.5);
  &-title {
    line-height: 40px;
    font-size: 20px;
  }
  &-type {
    span {
      width: 60px;
      padding: 0 15px;
    }
  }
}
</style>
